/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bus;

import dao.ContactDAO;
import dto.ContactDTO;
import java.sql.SQLException;
import java.util.ArrayList;

/**
 * Contact BUS
 * @author Hung Cuong <nhc.hcmuns at gmail.com>
 */
public class ContactBUS {
    private ContactDAO _Dao = new ContactDAO();

    /**
     * Insert contact
     * @param contact
     */
    public void insertContact(ContactDTO contact) {
        _Dao.insert(contact);
    }

    /**
     * Update contact
     * @param contact
     */
    public void updateContact(ContactDTO contact) {
        _Dao.update(contact);
    }

    /**
     * Delete contact
     * @param contact
     */
    public void deleteContact(ContactDTO contact) {
        _Dao.delete(contact);
    }

    /**
     * Search contact
     * @param fullname
     * @param company
     * @param jobTitle
     * @param email
     * @param displayAs
     * @param webpageAddress
     * @param imAddress
     * @return
     */
    public ArrayList<ContactDTO> search(String fullname, String company,
                                        String jobTitle, String email, String displayAs,
                                        String webpageAddress, String imAddress) {
        return _Dao.search(fullname, company, jobTitle, email, displayAs, webpageAddress, imAddress);
    }

    /**
     * Get all contacts
     * @return
     * @throws java.sql.SQLException
     */
    public ArrayList<ContactDTO> getAllRecords() throws SQLException {
        return _Dao.getAllRecords();
    }

    /**
     * Get contact information
     * @param contactId
     * @return
     * @throws java.sql.SQLException
     */
    public ContactDTO getInfo(int contactId) throws SQLException {
        return _Dao.getInfo(contactId);
    }
}
